package com.ruoyi.finance.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.finance.domain.WInvoiceInfo;
import com.ruoyi.finance.service.IWInvoiceInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 进项发票Controller
 * 
 * @author ruoyi
 * @date 2025-03-06
 */
@RestController
@RequestMapping("/WInvoiceInfo")
public class WInvoiceInfoController extends BaseController
{
    @Autowired
    private IWInvoiceInfoService wInvoiceInfoService;

    /**
     * 查询进项发票列表
     */
    @RequiresPermissions("finance:WInvoiceInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(WInvoiceInfo wInvoiceInfo)
    {
        startPage();
        List<WInvoiceInfo> list = wInvoiceInfoService.selectWInvoiceInfoList(wInvoiceInfo);
        return getDataTable(list);
    }

    /**
     * 导出进项发票列表
     */
    @RequiresPermissions("finance:WInvoiceInfo:export")
    @Log(title = "进项发票", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WInvoiceInfo wInvoiceInfo)
    {
        wInvoiceInfoService.export(response, wInvoiceInfo);
//        List<WInvoiceInfo> list = wInvoiceInfoService.selectWInvoiceInfoList(wInvoiceInfo);
//        ExcelUtil<WInvoiceInfo> util = new ExcelUtil<WInvoiceInfo>(WInvoiceInfo.class);
//        util.exportExcel(response, list, "进项发票数据");
    }

    /**
     * 获取进项发票详细信息
     */
    @RequiresPermissions("finance:WInvoiceInfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wInvoiceInfoService.selectWInvoiceInfoById(id));
    }

    /**
     * 新增进项发票
     */
    @RequiresPermissions("finance:WInvoiceInfo:add")
    @Log(title = "进项发票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WInvoiceInfo wInvoiceInfo)
    {
        return toAjax(wInvoiceInfoService.insertWInvoiceInfo(wInvoiceInfo));
    }

    /**
     * 修改进项发票
     */
    @RequiresPermissions("finance:WInvoiceInfo:edit")
    @Log(title = "进项发票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WInvoiceInfo wInvoiceInfo)
    {
        return toAjax(wInvoiceInfoService.updateWInvoiceInfo(wInvoiceInfo));
    }

    /**
     * 删除进项发票
     */
    @RequiresPermissions("finance:WInvoiceInfo:remove")
    @Log(title = "进项发票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wInvoiceInfoService.deleteWInvoiceInfoByIds(ids));
    }
}
